﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.Serialization.Json;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Text;
using Library.Wcf;
using log4net;

namespace ServiceHost1
{
    class Program
    {
        private static readonly ILog log = LogManager.GetLogger("Main_SH");

        static void Main(string[] args)
        {
            log.Info("SH started..");
            var userHost = new ServiceHost(typeof (UserWcfService), new Uri("http://localhost:4321/User"));
            var deviceHost = new ServiceHost(typeof (DeviceWcfService), new Uri("http://localhost:4321/Device"));


            //host.AddServiceEndpoint(typeof (DeviceWcfService), new Uri("http://localhost:4321/Device"));
            try
            {
                userHost.AddServiceEndpoint(typeof (IUserWcfService), new BasicHttpBinding(), "");
                deviceHost.AddServiceEndpoint(typeof (IDeviceWcfService), new BasicHttpBinding(), "");
                
                userHost.Open();
                deviceHost.Open();
                log.Info("WS uruchomiony, enter aby zakończyć");
                while(true)
                {
                }
                
                userHost.Close();
                deviceHost.Close();
            }
            catch(CommunicationException e)
            {
                Console.WriteLine("Problem z komunikacją: " + e.Message);
            }
            
            
            
            
            
            
            
            //host.AddServiceEndpoint(typeof (IUserWcfService), new BasicHttpContextBinding(), address2);
            



        }
    }
}
